<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01_组件嵌套</title>
    <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <style>
        .comment img{
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
    <div id="app"></div>
    <script type="text/babel">
        let app = document.getElementById('app')
        let {Component,Fragment} = React;
        class Comment extends Component {
            render(){
                return <div className="comment">
                    <User name={name} />
                    <h4>{this.props.commentText}</h4>
                    <p>{this.props.commentTime}</p>
                </div>
            }
        }

        class User extends Component {
            render(){
                // Fragment标签，可以成为一个占位标签，但是将来不会显示 类似于vue的template 小程序的block
                return <Fragment>
                    <Icon iconUrl={iconUrl} imgAlt={imgAlt} />
                    <h3>{this.props.name}</h3>
                </Fragment>
            }
        }

        class Icon extends Component{
            render(){
                return <Fragment>
                    <img src={this.props.iconUrl} alt={this.props.imgAlt} />
                </Fragment>
            }
        }

        let iconUrl = "http://cloud.pinggai8.com/upload/1645195304069hxxbims_kt=url&at=ori&key=aHR0cDovL2ltZy5xcXpoaS5jb20vdXBsb2Fkcy8yMDE4LTEyLTA0LzE1NDYxNzEzMy5qcGc=&sign=yx_DXqhW0Vj_3NzmK7d9bbhoX4hZbY=&tv=0_0.jpg";
        let name = "黑侠";
        let imgAlt = "头像"
        let commentText = "评论组件"
        let commentTime = new Date().toLocaleTimeString();

        ReactDOM.render(<Comment commentText={commentText} commentTime={commentTime} />,app)
    </script>
</body>
</html>